/* 产生随机数 */
export function getKeyRandom(y = 5) {
  let text = ''
  const possible =
    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
  for (let i = 0; i < y; i++) { text += possible.charAt(Math.floor(Math.random() * possible.length)) }
  return text
}

/* 添加条件节点 */
export function addApproval(i, _prevId, _childNode = {}) {
  const _node = {
    nodeId: 'approval_' + getKeyRandom(),
    prevId: _prevId,
    default: false, //! i
    name: '审批人' + (i + 1),
    nameEdit: false,
    conditions: [[]],
    type: 'apprParallel',
    placeholder: '请选择审批人',
    propertys: {
      type: 'manual',
      operaterType: 'target',
      operaters: '',
      mode: 'step',
      emptyOperater: 'failed',
      notifyOf: [],
      notifyOfType: 'target'
    }
  }
  if (_childNode.nodeId) {
    _node.childNode = _childNode
  }
  return _node
}
